package org.jeecg.modules.qyxx.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.modules.fk.entity.DjOrg;
import org.jeecg.modules.fk.service.IDjOrgService;
import org.jeecg.modules.qyxx.entity.BgNsrJbxx;
import org.jeecg.modules.qyxx.entity.TycSwpj;
import org.jeecg.modules.qyxx.mapper.BgNsrJbxxMapper;
import org.jeecg.modules.qyxx.service.IBgNsrJbxxService;
import org.jeecg.modules.qyxx.service.ITycSwpjService;
import org.jeecg.modules.system.service.ISysDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;

import java.util.List;

/**
 * @Description: 纳税人基本信息
 * @Author: ZJJ
 * @Date: 2021-06-09
 * @Version: V1.0
 */
// @DS("multi-datasource1")申报
@Service
public class BgNsrJbxxServiceImpl extends MppServiceImpl<BgNsrJbxxMapper, BgNsrJbxx> implements IBgNsrJbxxService {
    @Autowired
    private ISysDictService dictService;
    @Autowired
    private IDjOrgService djOrgService;
    @Autowired
    private ITycSwpjService tycSwpjService;

    @Override
    public BgNsrJbxx getQyxq(String nsrsbh) {
        LambdaQueryWrapper<BgNsrJbxx> wrapper = Wrappers.lambdaQuery(BgNsrJbxx.class); // industry_type
        wrapper.eq(BgNsrJbxx::getDjxh, nsrsbh);
        BgNsrJbxx jbxx = getOne(wrapper);
        DjOrg djOrg = djOrgService.getByNsrsbhOrShxydm(nsrsbh);
        List<DictModel> items = dictService.queryDictItemsByCode("industry_type");
        String industry = djOrg.getIndustry();
        String industryValue = "";
        if (industry != null) {
            for (DictModel item : items) {
                if (industry.equals(item.getValue())) {
                    industryValue = item.getText();
                }
            }
            jbxx.setBhsshy(industryValue);
        }
        return jbxx;
    }
}
